/**
 * 在let语句中使用if
 * 可以在let语句的右侧使用它
 */
fn main() {
    let condition = true;
    let number = if condition { 5 } else { 6 };
    // let number = if condition { 5 } else { "six" }; //将提示类型不匹配错误
    // let number = if condition { 5 } ; // false时，返回类型()，类型将不匹配
    // let number = if condition { 5 } else { () }; // 等同于上面
    println!("The value of number is: {number}");

    let result1 = if 1 == 2 {
        "Nothing makes sense" // 返回值
    } else {
        "Sanity reigns"
    };
    println!("Result of computation: {}", result1);

    // empty类型()
    let result2 = if 1 == 2 {
        "Nothing makes sense"; // 抛弃该值
    } else {
        "Sanity reigns"; //抛弃该值
    };
    println!("Result of computation: {:?}", result2);
}
